function UI_CreateButton ( text, x, y, w, h, parent )
	local ele = createElement ( "UI_Button" )
	setElementParent ( ele, parent or getResourceDynamicElementRoot ( sourceResource or getThisResource ( ) ) )

	setElementData ( ele, "UI_Text", text )
	setElementData ( ele, "UI_X", x )
	setElementData ( ele, "UI_Y", y )
	setElementData ( ele, "UI_Width", w )
	setElementData ( ele, "UI_Height", h )
	setElementData ( ele, "UI_Alpha", 255 )
	setElementData ( ele, "UI_RGB", { ["Red"] = 255, ["Green"] = 255, ["Blue"] = 255 } )
	setElementData ( ele, "UI_Font", "default-bold" )
	setElementData ( ele, "UI_FontSize", 1 )
	setElementData ( ele, "UI_ColorCoded", false )
	setElementData ( ele, "UI_Theme", UI_ThemeDefault )
	setElementData ( ele, "UI_EventMouseState", false )
	
	setElementData ( ele, "UI_RenderTarget", dxCreateRenderTarget ( w > 1 and w or 1, h > 1 and h or 1, true ) )

	w = w - UI_ThemeGetWidth ( "ButtonLeft", UI_ThemeDefault ) - UI_ThemeGetWidth ( "ButtonRight", UI_ThemeDefault )
	h = h - UI_ThemeGetHeight ( "ButtonTop", UI_ThemeDefault ) - UI_ThemeGetHeight ( "ButtonBottom", UI_ThemeDefault )
	setElementData ( ele, "UI_RenderTarget2", dxCreateRenderTarget ( w > 1 and w or 1, h > 1 and h or 1 ) )

	if ( parent ) then
		if ( not UI_RenderParent[parent] ) then UI_RenderParent[parent] = {} end
		table.insert ( UI_RenderParent[parent], ele )
	else
		table.insert ( UI_Render, ele )
	end
	return ele
end

function UI_ImageGeneratorButton ( ele )
	local Text = getElementData ( ele, "UI_Text" ) or " "
	local X = getElementData ( ele, "UI_X" ) or 0
	local Y = getElementData ( ele, "UI_Y" ) or 0
	local Width = getElementData ( ele, "UI_Width" ) or 0
	local Height = getElementData ( ele, "UI_Height" ) or 0
	local RGB = getElementData ( ele, "UI_RGB" ) or { ["Red"] = 255, ["Green"] = 255, ["Blue"] = 255 }
	local Font = getElementData ( ele, "UI_Font" ) or "default-bold"
	local FontSize = getElementData ( ele, "UI_FontSize" ) or 1
	if ( isElement ( Font ) and getElementType ( Font ) == "UI_Font" ) then
		Font = getElementData ( Font, "UI_Font" )
	end
	local Colored = getElementData ( ele, "UI_ColorCoded" ) or false
	local MouseState = getElementData ( ele, "UI_EventMouseState" ) or false
	local RenderTarget = getElementData ( ele, "UI_RenderTarget" )
	local RenderTarget2 = getElementData ( ele, "UI_RenderTarget2" )
	local Theme = getElementData ( ele, "UI_Theme" ) or UI_ThemeDefault
	local Selected = ( MouseState or UI_Selected == ele ) and "" or "S"

	dxSetRenderTarget ( RenderTarget2, true )
	
	local color = tocolor ( RGB["Red"], RGB["Green"], RGB["Blue"], 255 )

	if ( UI_Selected == ele ) then
		color = tocolor ( RGB["Red"], RGB["Green"], RGB["Blue"], 204 )
	end

	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonCenter", Theme )
	dxDrawImageSection ( 0, 0, Width - UI_ThemeGetWidth ( Selected .. "ButtonLeft", Theme ) - UI_ThemeGetWidth ( Selected .. "ButtonRight", Theme ), Height - UI_ThemeGetHeight ( Selected .. "ButtonTop", Theme ) - UI_ThemeGetHeight ( Selected .. "ButtonBottom", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	dxDrawText ( Text, ( Width - UI_ThemeGetWidth ( Selected .. "ButtonLeft", UI_ThemeDefault ) - UI_ThemeGetWidth ( Selected .. "ButtonRight", UI_ThemeDefault ) ) / 2, ( Height - UI_ThemeGetHeight ( Selected .. "ButtonTop", UI_ThemeDefault ) - UI_ThemeGetHeight ( Selected .. "ButtonBottom", UI_ThemeDefault ) ) / 2, color, FontSize, Font, "center", "center", _, Colored )
	dxSetRenderTarget ( )

	dxSetRenderTarget ( RenderTarget, true )
	dxDrawImage ( UI_ThemeGetWidth ( Selected .. "ButtonLeft", Theme ), UI_ThemeGetHeight ( Selected .. "ButtonTop", Theme ), Width - UI_ThemeGetWidth ( Selected .. "ButtonLeft", Theme ) - UI_ThemeGetWidth ( Selected .. "ButtonRight", Theme ), Height - UI_ThemeGetHeight ( Selected .. "ButtonTop", Theme ) - UI_ThemeGetHeight ( Selected .. "ButtonBottom", Theme ), RenderTarget2 )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonTop", Theme )
	dxDrawImageSection ( UI_ThemeGetWidth ( Selected .. "ButtonTopLeft", Theme ), 0, Width - UI_ThemeGetWidth ( Selected .. "ButtonTopLeft", Theme ) - UI_ThemeGetWidth ( Selected .. "ButtonTopRight", Theme ), ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonTopLeft", Theme )
	dxDrawImageSection ( 0, 0, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonTopRight", Theme )
	dxDrawImageSection ( Width - ThemeWidth, 0, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonLeft", Theme )
	dxDrawImageSection ( 0, UI_ThemeGetHeight ( Selected .. "ButtonTopLeft", Theme ), ThemeWidth, Height - UI_ThemeGetHeight ( Selected .. "ButtonTopLeft", Theme ) - UI_ThemeGetHeight ( Selected .. "ButtonBottomLeft", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonRight", Theme )
	dxDrawImageSection ( Width - ThemeWidth, UI_ThemeGetHeight ( Selected .. "ButtonTopLeft", Theme ), ThemeWidth, Height - UI_ThemeGetHeight ( Selected .. "ButtonTopLeft", Theme ) - UI_ThemeGetHeight ( Selected .. "ButtonBottomLeft", Theme ), ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonBottomLeft", Theme )
	dxDrawImageSection ( 0, Height - ThemeHeight, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonBottomRight", Theme )
	dxDrawImageSection ( Width - ThemeWidth, Height - ThemeHeight, ThemeWidth, ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage = UI_ThemeGetAll ( Selected .. "ButtonBottom", Theme )
	dxDrawImageSection ( UI_ThemeGetWidth ( Selected .. "ButtonBottomLeft", Theme ), Height - ThemeHeight, Width - UI_ThemeGetWidth ( Selected .. "ButtonBottomLeft", Theme ) - UI_ThemeGetWidth ( Selected .. "ButtonBottomRight", Theme ), ThemeHeight, ThemeXPos, ThemeYPos, ThemeWidth, ThemeHeight, ThemeImage )
	dxSetRenderTarget ( )

	return RenderTarget or nil
end

function UI_RenderButton ( ele )
	
	
end

